<div class="container-fluid">
	<div class="row-fluid">
		<div class="span4"></div>
		<div class="span4 login-span">
			<div class="login-radmin align-center">
				<h1 class="brand">
<!--					<span class="rad">Multi</span>WHM-->
					<img src="<?php echo baseUrl(); ?>/public/img/__whatever__-logo.png" />
				</h1>
			</div>
			<div class="login-wrapper">
				<div class="login-inner">
					<h2 class="sign-in">2-Factor Authentication</h2>
					<small class="muted">Please enter your Authy token to complete your login.</small>
					<div class="squiggly-border"></div>

					<div class="login-inner">
						<?php $form = $this->beginWidget('CActiveForm', array(
							'id' => 'user-authylogin-form',
							'enableClientValidation' => true,
							'clientOptions' => array(
								'validateOnSubmit' => true,
							),
							'htmlOptions' => array('class' => 'form-horizontal')
						)); ?>
							<?php echo CHtml::textField('authyLoginForm[authy-token]'); ?><br /><br />
							
							<?php $loginErrors = $user->getErrors(); ?>
							
							<?php if(!empty($loginErrors)): ?>
								<div class="row-fluid">
									<div class="span12">
										<div class="alert alter-block alert-error">
											<button type="button" class="close" data-dismiss="alert">&times;</button>
											<h4>Error</h4>
											<div class="content">
												<?php foreach($loginErrors as $k => $errors): ?>
													<?php foreach($errors as $error): ?>
<!--														<p><?php //echo $k; ?>: <?php //echo $error; ?></p>-->
														<p><?php echo $error; ?></p>
													<?php endforeach; ?>
												<?php endforeach; ?>
											</div>
										</div>
									</div>
								</div>
							<?php endif; ?>
					
							<div class="row-fluid">
								<div class="span12 hide" id="authylogin_info">
									<div class="alert alter-block alert-info">
							<!--			<button type="button" class="close" data-dismiss="alert">&times;</button>-->
										<div class="content"></div>
									</div>
								</div>
							</div>
							
							<div class="form-actions">
								<?php echo CHtml::ajaxLink('Send Token SMS', url('user/authysms'), array(
									'data' => array('id_user' => $user->id_user),
									'beforeSend' => 'function(){
										$("#authysms_btn").button("loading");
									}',
									'success' => 'function(ret){
										$("#authysms_btn").button("reset");
										if(ret.result){
											$("#authylogin_info").blink({
												"beforeCall": function(){
													$("#authylogin_info .content").html("");
													var p = $("<p />").append("Sms has been sent, please check.");
													$("#authylogin_info .content").append(p);
												}
											});
										}else{
											$("#authylogin_info").blink({
												"beforeCall": function(){
													$("#authylogin_info .content").html("");
													$.each(ret["errors"], function(attrName, error){
														$(error).each(function(k, e){
															//var p = $("<p />").addClass("text-error").append(attrName+": "+e);
															var p = $("<p />").addClass("text-error").append(e);
															$("#authylogin_info .content").append(p);
														});
													});
												}
											});
										}
									}',
									'dataType' => 'json'
								), array(
									'class' => 'btn-link pull-left', 
									'id' => 'authysms_btn', 
									'data-loading-text' => 'Sending...'
								)); ?>
								<?php echo CHtml::submitButton('Login', array('class' => 'btn btn-large btn-inverse pull-right')) ?>
							</div>
						<?php $this->endWidget(); ?>
					</div>

				</div>
			</div>
		</div>

		<div class="span4"></div>
	</div>

</div>